package com.xzx;

import com.xzx.annotation.bean.Person07;
import com.xzx.annotation.config.MainConfig;
import com.xzx.annotation.service.Service01;
import com.xzx.annotation.service.Service02;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.context.annotation.AnnotationConfigApplicationContext;

/**
 * @author xinzhixuan
 * @version 1.0
 * @date 2025/3/15 10:28
 */
public class Main {
    public static void main(String[] args) {
        AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext(MainConfig.class);
//        Object person = context.getBean("person");
        // 使用默认的日志框架
//        Log log = LogFactory.getLog(Main.class);
//        org.apache.commons.logging.impl.Jdk14Logger @ 2 b2948e2
//        log.info("person = " + person + "; log type =" + log);

        // 使用的log4j1
//        Log log = LogFactory.getLog(Main.class);
//         org.apache.commons.logging.impl.Log4JLogger@4d41cee
//        log.info("person = " + person + "; log type =" + log);

        // 使用log4j2+juc
//        Log log = LogFactory.getLog(Main.class);
        //org.apache.logging.log4j.jcl.Log4jLog@20ce78ec
//        log.info("person = " + person + "; log type =" + log);


        // 使用log4j2+slf4j, 这只是业务服务使用slf4j，spring自身的框架的还是使用log4j2
        Logger log = LoggerFactory.getLogger(Main.class);
        //org.apache.logging.slf4j.Log4jLogger@47af7f3d
        for (String name : context.getBeanDefinitionNames()) {
            log.info("===bean name:{}==>type:{}", name,  context.getBean(name).getClass());
        }

//        Object bean = context.getBean("&person05FactoryBean");
//        log.info("&person05FactoryBean = {}", bean);

        Service02 service02 = context.getBean(Service02.class);
        log.info("service02:{}", service02);
        context.close();

    }
}